/**
 * ============================================================
 * 版权：Autohome 版权所有 (c) 2014 - 2015
 * 文件：com.athm.framework.dao.PageParams.java
 * 所含类: zhangyongxin.java
 * 修改记录：
 * 日期 作者 内容
 * =============================================================
 * 2011-12-12 zhangyongxin 分页组件类
 * ============================================================
 */
package com.quanyou.base.framework.dao.model;

/**
 * <p>
 * PageParams
 * </p>
 * <p/>
 * <p>
 * 普通查询条件
 * </p>
 * <p/>
 * <p>
 * Copyright: 版权所有 (c) 2014 - 2015
 * </p>
 * <p>
 * Company:Autohome
 * </p>
 *
 * @author zhangyongxin
 * @version 1.0
 */
public class PageParams<T> {

    private T paramModel;

    /**
     * 总数
     */
    private Long pageIndex = 1L;
    /**
     * 一页大小
     */
    private Long pageSize = 30L;

    /**
     * 排序字段
     */
    private String orderBy;

    /**
     * 是否升序-默认是降序
     */
    private boolean asc;

    /**
     * Domain Class
     */
    private Class<?> domainClass;

    //private LinkedList<Order> orderList = new LinkedList<Order>();
/*    private LinkedList<OrderBy> mybatisOrderByList = new LinkedList<OrderBy>();

    public void addMybatisOrder(OrderBy orderBy) {
        if (orderBy != null) {
            this.mybatisOrderByList.add(orderBy);
        }
    }

    public LinkedList<OrderBy> getMybatisOrderByList() {
        return mybatisOrderByList;
    }
*/
/*  public void addOrder(Order order) {
    if (order != null) {
      this.orderList.add(order);
    }
  }

  public LinkedList<Order> getOrderList() {
    return this.orderList;
  }*/

    public PageParams() {
        super();
    }

    public boolean isAsc() {
        return asc;
    }

    public void setAsc(boolean asc) {
        this.asc = asc;
    }

    public T getParamModel() {
        return paramModel;
    }

    public T getPm() {
        return paramModel;
    }

    public void setParamModel(T paramModel) {
        this.paramModel = paramModel;
    }

    public Long getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Long pageIndex) {
        if (pageIndex <= 0) {
            pageIndex = 1L;
        }
        this.pageIndex = pageIndex;
    }

    public Long getPageSize() {
        if (pageSize <= 0) {
            pageSize = 1L;
        }
        return pageSize;
    }

    public void setPageSize(Long pageSize) {
        this.pageSize = pageSize;

    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public Long getResultsFrom() {
        return (pageIndex - 1) * pageSize;
    }

    public Long getResultsEnd() {
        return (pageSize) * pageIndex;
    }

    public Long getOffset() {
        return getResultsFrom();
    }

    public Long getLimit() {
        return this.pageSize;
    }

    public Class<?> getDomainClass() {
        return domainClass;
    }

    public void setDomainClass(Class<?> domainClass) {
        this.domainClass = domainClass;
    }

}
